Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/bank: use internal package #4521

Merged
merged 11 commits into from
Jun 14, 2019
Merged

x/bank: use internal package #4521

merged 11 commits into from
Jun 14, 2019

Conversation

alessio
Copy link
Contributor

@alessio alessio commented Jun 9, 2019

Reorganise x/bank packages and leverage internal special
package for enhanced encapsulation.

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
  • Wrote tests
  • Updated relevant documentation (docs/)
  • Added a relevant changelog entry: clog add [section] [stanza] [message]
  • rereviewed Files changed in the github PR explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alessio alessio changed the title x/bank: use internal pacakge x/bank: use internal package Jun 9, 2019
Reorganise x/bank sub-packages and leverage
internal special package for enhanced
encapsulation.
@codecov
Copy link

codecov bot commented Jun 9, 2019

Codecov Report

Merging #4521 into master will decrease coverage by 0.4%.
The diff coverage is 23.52%.

@@            Coverage Diff             @@
##           master    #4521      +/-   ##
==========================================
- Coverage   53.49%   53.09%   -0.41%     
==========================================
  Files         256      257       +1     
  Lines       16165    16285     +120     
==========================================
- Hits         8648     8646       -2     
- Misses       6870     6992     +122     
  Partials      647      647

@alessio alessio marked this pull request as ready for review June 9, 2019 06:07
@alessio alessio requested review from fedekunze and sabau June 9, 2019 06:07
@@ -1,15 +1,16 @@
package bank
package handler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm shouldn't this be under internal ?

Copy link
Contributor Author

@alessio alessio Jun 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it needs to be handler. I could move it under types

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's needs to be handler.

is it because a restriction from internal that it can't live underx/bank/internal/handler.go ? I'm fine with it as long as we update #4438

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about using internal just like other normal packages, i.e. dropping .go files in internal may not be permitted as internal may not compile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, don't we want files like abci.go and handler.go to live in the parent/root of the module and not under internal? I.e. I wouldn't like to see a module turn into everything being shoved into internal with just an alias.go at the root.

x/bank/internal/handler/handler_test.go Outdated Show resolved Hide resolved
@@ -1,12 +1,12 @@
package bank
package invariants
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be under keeper as other modules have it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import cycles - I'd keep this as it is

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? it shouldn't have any

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly - will double check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't think that that is the reason - bank's internal types depend on each other

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope of this PR is not to introduce functional changes/refactoring. So please as long as it works just +1 :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this should leave in keeper

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible @alessio? I don't mind helping out here!

x/bank/internal/tags/tags.go Outdated Show resolved Hide resolved
x/bank/internal/keeper/app_test.go Outdated Show resolved Hide resolved
x/bank/internal/invariants/msgs.go Outdated Show resolved Hide resolved
x/bank/internal/types/tags.go Show resolved Hide resolved
@alessio alessio requested a review from fedekunze June 10, 2019 17:20
@alexanderbez alexanderbez added Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. T: Dev UX UX for SDK developers (i.e. how to call our code) ready-for-review labels Jun 11, 2019
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM -- thanks @alessio. I don't think all the choices made here though are fully agreed upon. Namely, simulation messages and what should live under the root of the module. I don't want to see us starting to shove everything under internal/.

@@ -1,15 +1,16 @@
package bank
package handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, don't we want files like abci.go and handler.go to live in the parent/root of the module and not under internal? I.e. I wouldn't like to see a module turn into everything being shoved into internal with just an alias.go at the root.

x/bank/internal/invariants/msgs.go Outdated Show resolved Hide resolved
@alessio
Copy link
Contributor Author

alessio commented Jun 11, 2019

Comments were addressed

x/bank/alias.go Show resolved Hide resolved
Co-Authored-By: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
@alexanderbez
Copy link
Contributor

Closing this issue for now @alessio. Let's discuss further as most believe that this may not be the best approach after all. May potentially reopen after 👍

@alessio
Copy link
Contributor Author

alessio commented Jun 13, 2019

Reopening this

@alessio alessio reopened this Jun 13, 2019
@alessio
Copy link
Contributor Author

alessio commented Jun 13, 2019

  • Promote handler.go to top-level package
  • Promote simulation msgs to top-level

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few structural changes required + clog entry

@@ -1,12 +1,12 @@
package bank
package invariants
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this should leave in keeper

x/bank/module.go Outdated Show resolved Hide resolved
x/bank/module.go Outdated
@@ -90,7 +91,7 @@ func (AppModule) Name() string {

// register invariants
func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
RegisterInvariants(ir, am.accountKeeper)
invariants.RegisterInvariants(ir, am.accountKeeper)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

x/bank/msgs.go Outdated
@@ -1,4 +1,4 @@
package simulation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should remain in the simulation package

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor nitpicks, but otherwise LGTM 👍

@@ -1,11 +1,13 @@
package bank
package bank_test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this file abci_test.go and the corresponding file to abci.go?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file contains a lot of mixed tests (some from keepers and others from msgs). I'd consider addressing this in a follow PR

x/bank/alias.go Show resolved Hide resolved
x/bank/msgs.go Outdated
@@ -1,4 +1,4 @@
package simulation
package bank
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this structure as-is/unchanged (i.e. x/bank/simulation/*)? I believe this is the pattern we want to follow in modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we said we wanted to keep only client as top-level package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simulation messages live top-level already, isn't that OK?

@@ -1,12 +1,12 @@
package bank
package invariants
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this possible @alessio? I don't mind helping out here!

@alessio alessio requested a review from fedekunze June 14, 2019 13:54
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@alessio alessio merged commit 1e9ca4a into master Jun 14, 2019
@alessio alessio deleted the alessio/bank-internal branch June 14, 2019 14:10
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Reorganise x/bank packages and leverage internal special
package for enhanced encapsulation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Dev UX UX for SDK developers (i.e. how to call our code) Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants